<script setup lang="ts">
import { ref } from 'vue';
import { handleMessage } from '@/utils/globalEvent';

// 触发父组件事件
const emits = defineEmits(['handleSend']);

// 聊天框内容
const sendMessage = ref<string>('');

// 点击发送消息
const handleSend = () => {
	// 输入框消息为空时
	if (!sendMessage.value) return handleMessage('请输入消息内容', 'warning');
	emits('handleSend', sendMessage.value);
	sendMessage.value = '';
};
</script>

<template>
	<div class="chat-send">
		<input v-model="sendMessage" class="send" type="text" @keyup.enter="handleSend" />
		<div class="send-submit" @click="handleSend">发送</div>
	</div>
</template>

<style lang="less" scoped>
@import url('./index.less');
</style>
